﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Cotrobaie
{
    public partial class AdminLog : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["AdminLogat"] != null) { Session["AdminLogat"] = null; }
        }

        protected void ButtonLog_Click(object sender, EventArgs e)
        {
            var v = NonPublic.LoginAdmin(TextBoxUserLogin.Text, TextBoxPasLogin.Text);
            if (v.Success)
            {
                Session["AdminLogat"] = TextBoxUserLogin.Text;
                Response.Redirect("AdminEditUser.aspx");
            }
            else
            {
                CustomValidator1.ErrorMessage = v.Mesaj;
                CustomValidator1.IsValid = false;
            }
        }

        protected void goHome(object sender, EventArgs e)
        {
            Response.Redirect("~/Home.aspx");
        }
    }
}